/**
 * \file actions.h
 * \author Ameen Jaber
 * \author Mohamad Noureddine
 * \author Mohamed Sabra
 * \brief Definitions of action methods
*/
#ifndef ACTIONS_H_
#define ACTIONS_H_

#include <util.h>
#include <defs.h>

/**
 * \brief Initialize parsing
 * @return Return the id of the root node
 */
int tunit_initialize(TPGraph_t * //!< The input parse graph 
		);

/**
 * \brief Update the graph with new edge to the root
 */
void tunit_updateroot(TPGraph_t *, //!< The input parse graph
		int, //!< The id of the root node
		int, //!< The id of the node to connect to 
		int  //!< The edge count 
		); 

/**
 * \brief Add new integer node to parse graph
 * @return return id of the inserted node
 */
int int_update(TPGraph_t * //!< The input parse graph
		);

/**
 * \brief Check if left value identifier is found
 * @return returns the id of the identifer's node if found, else returns -1
 */
int lvalue_id(TPTable_t *, //!< The input variables table
	     std::string //!< The variable's name
	     );

/**
 * \brief Add a new node for the additive +/- expression
 * @return returns the node id of the operator's node
 */
int additive_update(TPGraph_t *,//!< The input parse graph
		int,//!< The node id of the left value
		int,//!< The node id of the right value
		int //!< The type of the operation (1 = + , 2 = -)
		);

/**
 * \brief Add a new for the multiplicative mult / '/' / % expression
 * @return returns the node id of the operator's node
 */
int multiplicative_update(TPGraph_t *,//!< The input parse graph
		int,//!< The node id of the left value
		int,//!< The node id of the right value
		int //!< The type of the operation (1 = * , 2 = /, 3 = %)
		);

/**
 * \brief Add a new node for the power expression 
 * @return returns the node if of the operator's node 
 */
int power_update(TPGraph_t *,//!< The input parse graph
		int,//!< The node id of the left value
		int //!< The node id of the right value
		);

/**
 * \brief create a new node for the unary operator
 * @return returns the node id of the unary operator's node
 */
int cast_update (TPGraph_t *,//!< The input parse graph
		int,//!< The vid of the expression after the unary operator
		int //!< The type of the unary operator
		);
	
/**
 * \brief Add a new node for the access operator
 * @return returns the node id of the access operator's node
 */
int postfix_update(TPGraph_t *,//!< The input parse graph
		int,//!< The vid of the left expression
		int //!< The vid of the right expression
		);

/**
 * \brief Create a node for a constant
 * @return returns the id of the created node
 */
int create_constant(TPGraph_t *,//!< The input parse graph
		int //!< The value of the constant node
		);

/**
 * \brief Add a new node for the assignment operator
 * @return returns the node id of the assignment operator's node
 */
int assignment_update(TPGraph_t *,//!< The input parse graph 
		      int, //!< The vid of the left expression
		      int //!< The vid of the right expression
		      );

/**
 * \brief Add a new node for the equality operator
 * @return returns the node id of the equality operator's node
 */
int relational_update(TPGraph_t *,//!< The input parse graph
		      int, //!< The vid of the left expression
		      int, //!< The vid of the right expression
		      TP_Op_t //!< The type of the relational operator
		      );

/**
 * \brief Add a new node for the logical and operator
 * @return returns the node id of the logical and operator's node
 */
int logical_and_update(TPGraph_t *,//!< The input parse graph
		      int, //!< The vid of the left expression
		      int //!< The vid of the right expression
		      );

/**
 * \brief Add a new node for the logical or operator
 * @return returns the node id of the logical or operator's node
 */
int logical_or_update(TPGraph_t *,//!< The input parse graph
		      int, //!< The vid of the left expression
		      int //!< The vid of the right expression
		      );

/**
 * \brief Add a new node for the equality operator
 * @return returns the node id of the equality operator's node
 */
int equality_update(TPGraph_t *,//!< The input parse graph
		      int, //!< The vid of the left expression
		      int //!< The vid of the right expression
		      );
/**
 * \brief Add a new node for the iterator expression
 * @return returns the node id of the iterator expression node
 */
int iterator_create(TPGraph_t * //!< The input parse graph
		      );


/**
 * \brief Check if the variable is defined or not
 * @return returns -1 if error and returns the id of the variable's node
 */
int iterator_check(TPTable_t *,//!< The input variables table
		   std::string index //!< The variable name
		   );

/**
 * \brief Connect the iteranor nodes to the iterator root
 * @return returns 1 if successfull and -1 if not 
 */
int iterator_connect(TPGraph_t *,//!< The input parse graph
		     int,//!< The id of the expression's root
		     int,//!< The id of the connecting node
		     int //!< The count of edges for labeling 
		     );

/**
 * \brief Add a new node for the conditinal expression
 * @return returns the node id of the conditional expression node
 */
int conditional_create(TPGraph_t *, //!< The input parse graph
		       int //!< The type of the node to create
		      );

/**
 * \brief Connect the conditional nodes to the conditional root
 * @return returns 1 if successfull and -1 if not 
 */
int conditional_connect(TPGraph_t *,//!< The input parse graph
		     int,//!< The id of the expression's root
		     int,//!< The id of the connecting node
		     int //!< The count of edges for labeling 
		     );

/**
 * \brief Add a new node for the while expression
 * @return returns the node id of the while expression node
 */
int while_create(TPGraph_t * //!< The input parse graph
		      );

/**
 * \brief Connect the while nodes to the while root
 * @return returns 1 if successfull and -1 if not 
 */
int while_connect(TPGraph_t *,//!< The input parse graph
		     int,//!< The id of the expression's root
		     int,//!< The id of the connecting node
		     int //!< The count of edges for labeling 
		     );

/**
 * \brief Update the relation set expressions
 * @return returns the id of the opertor node
 */
int relation_set_update(TPGraph_t *,//!< The input parse graph
			int,//!< The id of the left node 
			int,//!< The type of the operator
			int //!< The id of the right node
			);

/**
 * \brief Add a new node for the scast expression
 * @return returns the node id of the scast expression node
 */
int scast_create(TPGraph_t * //!< The input parse graph
		 );

/**
 * \brief Connect the edges to the unary id 
 * @return returns 1 if successfull and -1 if not
 */
int scast_connect(TPGraph_t *,//!< The input parse graph
		  int,//!< The id of the unary node
		  int //!< The id of the expression node 
		  );

/**
 * \brief Check if the variable is defined or not
 * @return returns -1 if not define, -2 if not a set and returns the id of the variable's node if found
 */
int spostfix_check(TPTable_t *,//!< The input variables table
		    TPGraph_t *,//!< THe input parse graph
		    std::string //!< The variable name 
		    );

/**
 * \brief Create a node for the cardinality operation
 * @return returns the id of the created node 
 */
int cardinality_update(TPGraph_t *,//!< The input parse graph
		       int //!< The of the expression's node
		       );

/**
 * \brief Create a new node in the graph for a custom variable
 * @retrurn returns the id of the created node
 */
int custom_update(TPGraph_t * //!< The input parse graph
		  );

#endif
